<%@ page language="java" import="cn.edu.bit.dto.WebPage;" pageEncoding="UTF-8"%>
<%
String isAllowed = request.getParameter("isAllowed");
if(isAllowed==null||!isAllowed.equals("101")){
	response.sendRedirect("/mermaid");
	return;
}
WebPage[] result = (WebPage[])session.getAttribute("result");
int totalPage = (Integer)session.getAttribute("totalPage");
int currentPage = Integer.valueOf(request.getParameter("currentPage"));
String keyWord = request.getParameter("keyWord");
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>    
    <title>Mermaid</title> 
  </head>  
  <body> 
  	<form action="searching" name="Search" method="get">
    <table width="1024" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="250"><div align="center"><img src="Pic/Title1.jpg" width="351" height="138"></div></td>
        <td width="774"><input type="text" name="keyWord" value="<%=keyWord%>" maxlength="100" size="50"/><input type="submit"  value="Mermaid 搜索"/></td>
      </tr>
    </table>
    </form>
    <%if(result.length==0){
    		out.print("未找到符合要求的结果！");
        }else{%>
    
				<%for(int i = 0;i<result.length;i++){
						if(result[i]==null) break; %>
						<a href=<%=result[i].getURL()%> target="blank"><%=result[i].getTitle()%></a><br>			
						<%=result[i].getContent()%><br>			
						<font color="Green" size="3"><%=result[i].getURL()%></font><br>
						<br>
				<%} %>
				<br>
				<br>
				<br>
				<div align="center">
				<%for(int i = currentPage>11 ? currentPage - 10 : 1;i<currentPage;i++){%>	
						<a href="searching?keyWord=<%=keyWord%>&pageNumber=<%=i%>"><%=i%></a>
				<%}%>
				<font color="red"><%=currentPage%></font>
				<%	int j = 0;
					for(int i = currentPage+1;i<=totalPage&&j<9;i++,j++){%>	
						<a href="searching?keyWord=<%=keyWord%>&pageNumber=<%=i%>"><%=i%></a>
				<%}%>
				</div>
  			<%}%>
</body>
</html>
